package com.xiaoyun.util.sw;

/**
 * @Author: XiaoYun461
 * @Date: 2022/2/21 21:06
 */
public interface BaseSplit {


    /**
     * 根据类名 分包
     *
     * @param name
     * @return
     */
    default String preNameAndEndNameGroup(String thisPackage, String name, String[] pre) {
        StringBuilder sb = new StringBuilder(thisPackage);
        for (int i = 0; i < pre.length; i++) {
            String preName = pre[i];
            if (name.startsWith(pre[i])) {
                sb.append(".").append(preName.substring(0, 1).toLowerCase()).append(preName.substring(1));
            }
        }
        if (name.toLowerCase().endsWith("controller")) {
            sb.append(".").append("controller");
        } else {
            sb.append(".").append("pojo");
        }
        if (name.endsWith("BO")) {
            sb.append(".").append("bo");
        } else if (name.endsWith("PO")) {
            sb.append(".").append("po");
        } else if (name.endsWith("VO")) {
            sb.append(".").append("vo");
        }
        return sb.toString();

    }
}
